//
// Created by xili on 2024/8/27 19:38.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    vector<int> resultsArray(vector<int> &nums, int k) {
        vector<int> ans;
        int n = nums.size();
        for (int i = k - 1; i < n; i++) {
            if (ok(nums, i - k + 1, i)) {
                ans.push_back(nums[i]);
            } else {
                ans.push_back(-1);
            }
        }
        return ans;
    }

    bool ok(vector<int> &nums, int l, int r) {
        for (int i = l; i < r; i++) {
            if (nums[i + 1] - nums[i] != 1) {
                return false;
            }
        }
        return true;
    }
};